from django.db import models
from rest_framework import serializers




# Create your models here.

class Ract(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30, null=True, verbose_name="机柜名称")
    position = models.CharField(max_length=100, null=True, verbose_name="机柜位置")
    status = models.CharField(max_length=100, null=True, verbose_name="机柜状态")
    create_time = models.DateField(null=True, verbose_name="创建时间", )
    update_time = models.DateField(null=True, verbose_name="更新时间")
    remark = models.CharField(max_length=500, null=True, verbose_name="备注")

    class Meta:
        db_table = "sys_ract"


class SysRactSerializer(serializers.ModelSerializer):
    class Meta:
        model = Ract
        fields = '__all__'

# 系统角色类
class Datacenter(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30, null=True, verbose_name="机房名称")
    position = models.CharField(max_length=100, null=True, verbose_name="机房位置")
    create_time = models.DateField(null=True, verbose_name="创建时间", )
    update_time = models.DateField(null=True, verbose_name="更新时间")
    remark = models.CharField(max_length=500, null=True, verbose_name="备注")

    class Meta:
        db_table = "sys_datacenter"


class SysDacenterSerializer(serializers.ModelSerializer):
    class Meta:
        model = Datacenter
        fields = '__all__'





# 机房机柜关联类
class SysCenterRact(models.Model):
    id = models.AutoField(primary_key=True)
    center = models.ForeignKey(Datacenter, on_delete=models.PROTECT)
    ract = models.ForeignKey(Ract, on_delete=models.PROTECT)

    class Meta:
        db_table = "sys_cen_ract"


class SysCenRactSerializer(serializers.ModelSerializer):
    class Meta:
        model = SysCenterRact
        fields = '__all__'

